#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
//定义一个全局变量
int glav=5;
int main(){
    pid_t pid=fork();
    if(pid==0){
        while(glav){
            printf("i am child mypid=%d,glav=%d\n",getpid(),glav);
            glav--;
            sleep(1);
        }
    }else{
        while(1){
        printf("i am parent mypid=%d,glav=%d\n",getpid(),glav);
        sleep(1);
    }
    }
    return 0;
}
